home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 65.zip / BS1 part 65 / Chemistetics v2.00.adf / STV / source / text.c < prev    next >
C/C++ Source or Header  |  1991-01-09  |  2KB  |  98 lines

  1. /*********************************
  2. *  TEXT  01/02/91
  3. *  Source file for STV
  4. *  © Copyright 1990 Timm Martin
  5. *  All Rights Reserved Worldwide
  6. **********************************/
  7.  
  8. #include <exec/types.h>
  9. #include <functions.h>
  10. #include <intuition/intuition.h>
  11. #include <string.h>
  12. #include "func.h"
  13. #include "main.h"
  14.  
  15. /****************
  16. *  TEXT DISPLAY
  17. *****************/
  18.  
  19. /*
  20. This procedure displays all text lines in the window.
  21. */
  22.  
  23. void text_display( void )
  24. {
  25.   int bottom;
  26.   int line;
  27.   long top;
  28.  
  29.   if (stats.Top + current_file.Lines < stats.Rows)
  30.     bottom = current_file.Lines - stats.Top;
  31.   else
  32.     bottom = stats.Rows;
  33.  
  34.   for (line = 0, top = stats.TopEdge; line < bottom;
  35.        line++, top += stats.TextHeight)
  36.   {
  37.     SetAPen( rp, BLUE );
  38.     RectFill( rp, (long)stats.LeftEdge, top,
  39.                   (long)stats.RightEdge, top + stats.TextHeight - 1 );
  40.     text_line( line );
  41.   }
  42. }
  43.  
  44. /*************
  45. *  TEXT LINE
  46. **************/
  47.  
  48. /*
  49. This procedure displays the specified line in the window (the 'line' is
  50. relative position in the window, not the file).  This procedure assumes the
  51. text line has already been cleared, either by ScrollRaster() or by RectFill().
  52. */
  53.  
  54. void text_line( int line )
  55. {
  56.   int length;            /* length of string to be printed */
  57.   REG char *s;           /* for stepping thru line */
  58.  
  59.   s = current_file.Table[stats.Top + line];
  60.  
  61.   if ((length = strlen( s )) > stats.Cols)
  62.     length = stats.Cols;
  63.   SetAPen( rp, (long)arguments.TextColor );
  64.   Move( rp, (long)stats.LeftEdge,
  65.         (long)(stats.TopEdge + stats.Baseline + line * stats.TextHeight) );
  66.   Text( rp, s, (long)length );
  67. }
  68.  
  69. /***************
  70. *  TEXT STRING
  71. ****************/
  72.  
  73. /*
  74. This procedure displays a specified text string in the window.  The 'line' is
  75. the relative position in the window, not the file).
  76. */
  77.  
  78. void text_string( int line, int start, int length )
  79. /*
  80.   line ..... relative position in window
  81.   start .... starting char position in line
  82.   length ... number of chars to display
  83. */
  84. {
  85.   int diff;  /* how far string goes past end */
  86.  
  87.   /* only do this if not off the end */
  88.   if (start < stats.Cols)
  89.   {
  90.     if ((diff = start + length - stats.Cols) > 0)
  91.       length -= diff;
  92.     SetAPen( rp, RED );
  93.     Move( rp, (long)(stats.LeftEdge + start * stats.TextWidth),
  94.           (long)(stats.TopEdge + stats.Baseline + line * stats.TextHeight) );
  95.     Text( rp, current_file.Table[stats.Top + line] + start, (long)length );
  96.   }
  97. }
  98.